import Toast from 'react-native-toast-message';

import { t } from 'i18next';

export class showToast {
  static success(text: string) {
    Toast.show({
      type: 'success',
      text1: t(text),
    });
  }
  static error(text: string) {
    Toast.show({
      type: 'error',
      text1: t(text),
      // text2: 'Please reopen the app',
    });
  }

  static musicToastGenerated(callback: () => void) {
    this.musicToast(t('AI music is being generated'), t("You will be notified when it's done～"), callback);
  }

  static musicToast(title: string, subTitle: string, callback: () => void) {
    Toast.show({
      type: 'musicToast',
      props: {
        _title: t(title),
        _subTitle: t(subTitle),
        _isShowJumpIcon: true,
        _onHide: callback,
      },
    });
  }

  static toastSuccess(text: string) {
    Toast.show({
      type: 'tips',
      text1: t(text),
      props: {
        _type: 'success',
      },
    });
  }

  static toastWarning(text: string) {
    Toast.show({
      type: 'tips',
      text1: t(text),
      props: {
        _type: 'warning',
      },
    });
  }

  static lightWeightToast(message: string) {
    Toast.show({
      type: 'lightWeightToast',
      props: {
        _message: t(message),
      },
    });
  }

  static toastOperationFailure() {
    this.toastWarning(t('Operation failed, please try again'));
  }
}
